/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package simhya.model.flat;

import java.util.ArrayList;
import simhya.model.store.*;
import simhya.model.transition.Transition;
import simhya.model.transition.AtomicReset;
import simhya.model.transition.TType;

/**
 *
 * @author Luca
 */
public interface FlatModel {
    
    public void setStore(Store store);
    public int addTransition(Transition t);
    public boolean isInitialized();

    public int getNumberOfTransitions();
    public int getNumberOfInstantaneousTransitions();
    public int[] getListOfInstantaneousTransitionsID();
    public int getNumberOfTimedTransitions();
    public int[] getListOfTimedTransitionsID();
    /**
     * returns the number of stochastic transitions
     * @param force if true, all continuous and hybrid transitions will be considered as
     * stochastic
     * @return
     */
    public int getNumberOfStochasticTransitions(boolean force);
    /**
     * returns the list of ids of stochastic transitions
     * @param force if true, all continuous and hybrid transitions will be considered as
     * stochastic
     * @return
     */
    public int[] getListOfStochasticTransitionID(boolean force);
    /**
     * returns the number of continuous transitions
     * @param force if true, all hybrid transitions and all continuously
     * consistent stochastic transitions will be counted
     * @return
     */
    public int getNumberOfContinuousTransitions(boolean force);
    /**
     * returns the list of ids of continuous transitions
     * @param force if true, all hybrid transitions and all continuously
     * consistent stochastic transitions will be counted
     * @return
     */
    public int[] getListOfContinuousTransitionID(boolean force);
    /**
     * returns the number of hybrid transitions
     * @return
     */
    public int getNumberOfHybridTransitions();
    /**
     * returns the list of ids of hybrid transitions
     * @return
     */
    public int[] getListOfHybridTransitionID();

    public boolean evaluateGuard(int transitionID);
    public boolean getCurrentGuardStatus(int transitionID);
    public double computeRate(int transitionID);
    public double computeNextFiringTime(int transitionID, double time);
    public void execute(int transitionID);
    public boolean isStopping(int transitionID);
    public boolean isStoppingAfterDelay(int transitionID);
    public TType getTransitionType(int transitionID);
    public String getTransitionName(int transitionID);

    public void finalizeInitialization();
    public Integer[] getListOfUpdatedGuards(int transitionID);
    public Integer[] getListOfUpdatedRates(int transitionID);
    public Integer[] getListOfUpdatedFiringTimes(int transitionID);
    public Integer[] getListOfUpdatedGuardsAfterDelay(int transitionID);
    public Integer[] getListOfUpdatedRatesAfterDelay(int transitionID);
    public Integer[] getListOfUpdatedFiringTimesAfterDelay(int transitionID);


    public ArrayList<Integer> getIdOfVariables(ArrayList<String> list);
    public double[] getVariablesValues();
    public String getName();

    public void setValueOfVariable(String var, double value);
    public void setValueOfParameter(String param, double value);
    /**
     * Resets the model to its initial state, as specified in the model file
     */
    public void resetToInitialState();
    /**
     * Resets all variables and parameters that have a numeric initial value to their initial state
     */
    public void resetToBasicInitialState();
    /**
     * Computes the initial state of parameter and variables having an initial value defined by an
     * expression.
     */
    public void computeInitialValues();

    public void changeVariableValue(String name, double newValue);
    public void changeParameterValue(String name, double newValue);

    public Store getStore();
    public Predicate[] getTransitionGuards();
    public Function[] getTransitionRates();
    public TType[] getTransitionTypes();
    public String[] getTransitionEvents();
    public Function[] getTransitionTimedActivations();
    public Function[] getTransitionDelays();
    public AtomicReset[][] getTransitionResets();
    public Predicate[] getTransitionDelayedGuards();
    public AtomicReset[][] getTransitionDelayedResets();
    public boolean[] getTransitionStoppingStatus();
    public boolean[] getTransitionStoppingStatusAfterDelay();

    public boolean containsExplorableVariable(String name);
    public boolean containsExplorableParameter(String name);
    public boolean containsDelayedTransitions();
    public boolean containsInstantaneousTransitions();
    public boolean containsTimedTransitions();
    public boolean containsGuardedTransitions();
    /**
     * returns true if the model contains only stochastic transitions
     * @param forceStochastic if true, all hybrid and continuous transitions
     * will be considered stochastic
     * @return
     */
    public boolean containsOnlyStochasticTransitions(boolean forceStochastic);
    /**
     * returns true if the model contains only continuosu transitions
     * @param force if true, then all hybrid and stochastic transitions that are continuously
     * approximable will be considered continuous.
     * @return
     */
    public boolean containsOnlyContinuousTransitions(boolean force);
    public boolean containsNonContinuouslyApproximableStochasticTransitions();
    public int getAverageNumberOfTransitionsToUpdate();

    public String toModelLanguage();
    public void saveToFile(String filename);

    public void recomputeDependencyGraphs(boolean computeRateAfterGuard);
    public void recomputeDependencyGraphs();
}
